cartPage()
/**
 * 渲染购物车数据
 */
function cartPage(){
  let cartMsg = JSON.parse(localStorage.getItem('MYCARTMSG')) || []

  let msgArr = Array.from(cartMsg).map(item=>{
    return `
      <tr>
        <td>
          <input type="checkbox" name="checkItem">
        </td>
        <td class="shop-name">${item.shopName.slice(0,10)}</td>
        <td class="price">${item.singlePrice}</td>
        <td class="num">
          <p>
            <span class="cut">-</span>
            <input type="test" value="${item.num}" disabled>
            <span class="plus">+</span>
          </p>
        </td>
        <td class="sub-price">${item.singlePrice * item.num}</td>
        <td class="delete">x</td>
      </tr>
    
    `
  })

  let str = `


  `

  $('tbody').html(msgArr.join(''))

 
}
/**
 * 数量加减
*/
numChange()
function numChange(){
  let cutList = document.querySelectorAll('.cut')
  let plusList = document.querySelectorAll('.plus')
  
  let cartMsg = JSON.parse(localStorage.getItem('MYCARTMSG')) || []
  console.log(cartMsg)

  for(var i = 0; i<cutList.length; i++){

    cutList[i].onclick= function(){
      console.log(this)
      if(this.nextElementSibling.value > 0){
        this.nextElementSibling.value--
     
      }
    }

    plusList[i].onclick = function(){
      this.previousElementSibling.value++
    
    }
  }
  
}

/**
 * 计算价格
 */

// function sub(){
//   let num = document.querySelector('input[type=test]').value
//   let subPrice = 1
//   let price = document.querySelector('.price').innerHTML
//   subPrice = (price * num).toFixed(2)

//   document.querySelectorAll('.sub-price').innerHTML = subPrice
// }